<!-- MyApplication.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>我的应用</title>
		<link rel="stylesheet" href="./css/base.css"/>
		<link rel="stylesheet" href="./css/CFNetPP_Base.css">
		<style type="text/css">
			html,body{
				background-color: white;
			}
		</style>
	</head>
	<body>
		<div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%"></div>
		<!-- <div class="base_navigation_bar base_style_color base_navigation_item_bar">
			<a class="base_left_item" href="#" onclick="backClick()"> <img class="base_back_icon" src="./image/icon_jiantou.png" alt=""> </a>
			<span>我的应用</span>
			<a class="base_right_item nav-item" href="#" onclick="testClick()">
				测试
			</a>
		</div> -->
	</body>
	<script type="text/javascript" src="./script/jquery.min.js"></script>
	<script type="text/javascript" src="./script/api.js"></script>
	<script type="text/javascript" src="./script/MD5.js"></script>
	<script type="text/javascript" src="./script/requestTool.js"></script>
	<script type="text/javascript">
		apiready = function() {
			setupFrame();
			setupNotifi();
		};
		function setupNotifi(){
			api.addEventListener({
			    name: 'WebPageNotifi'
			}, function(ret, err) {
				var type = ret.value.id;
				if (type == 1) {
					backClick();
				}
			});
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {

			});
		}
		function setupFrame() {
			var uid = $api.getStorage('cfnetppuid');
			var uname = $api.getStorage('cfnetppusername');
			var jid = $api.getStorage('cfnetppjxid');
			var stoken = MD5(jid+uid+uname+'cfnetapp');
			var url = 'http://m.xueba.cfnet.org.cn/index.php/examsystem/index/index?uid='+uid+'&jid='+jid+'&uname='+uname+'&stoken='+stoken+'&sources=3';
			if (urlPrefix == 'http://base.cfnet.org.cn/index.php/') {
				url = 'http://test.m.cfnet.org.cn/index.php/examsystem/index/index?uid='+uid+'&jid='+jid+'&uname='+uname+'&stoken='+stoken+'&sources=3';
			}
			api.openFrame({
			    name : 'MyApplicationFrame',
				url : url,
			    rect: {
			        x: 0,
			        y: 20,
			        w: 'auto',
			        h: api.winHeight
			    },
			    bounces: false
			});
			console.log(url);
		}
		function copyString(string){
			var paste = api.require('pasteboard');
			var param = { value: string };
			paste.paste(param, function(ret, err) {
			    if (ret.status) {
			        api.alert({
			            title: '返回信息',
			            msg: 'statues:' + ret.status,
			            buttons: ['确定']
			        }, function(ret, err) {});
			    } else {
			        api.alert({
			            title: '返回信息',
			            msg: 'msg:' + ret.msg + 'code:'+err.code,
			            buttons: ['确定']
			        }, function(ret, err) {});
			    }
			});
		}
		function testClick(){
			api.sendEvent({
			    name: 'testAlertNotifi',
			    extra: {
			        id: 1, 
			        name: 'test'
			    }
			});
		}
		function backClick() {
			api.closeWin();
		}
	</script>
</html>